home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77719_Ftp_MasterSettings.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  24.7 KB  |  818 lines

  1. <%@ Language=VBScript     %>
  2.  
  3. <%    Option Explicit       %>
  4.  
  5. <%
  6.     '------------------------------------------------------------------------- 
  7.     ' FTP_MasterSettings.asp: Set FTP Master Settings Values
  8.     '
  9.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  10.     '
  11.     ' Date            Description    
  12.     ' 08-11-2000    Created date
  13.     ' 15-01-2001    Modified for new Framework
  14.     '-------------------------------------------------------------------------
  15. %>
  16.  
  17. <!--  #include virtual="/admin/inc_framework.asp"--->
  18. <!-- #include virtual="/admin/wsa/inc_wsa.asp" -->
  19.  
  20. <% 
  21.     '-------------------------------------------------------------------------
  22.     ' Form Variables
  23.     '-------------------------------------------------------------------------
  24.  
  25.     Dim F_FTPEnabled                     'Whether FTP service is enabled (started) or not
  26.     Dim F_selectDirListStyle             'Directory Listing Style    
  27.     Dim F_FTPMaxCon                         'Maximum Connections     
  28.     Dim F_FTPCon_Timeout                 'Conection Time out
  29.     Dim FTPInstalled                     'Holds a boolean value to check whether FTP 
  30.                                          'service is installed    
  31.  
  32.     '-------------------------------------------------------------------------
  33.     ' Global Variables
  34.     '-------------------------------------------------------------------------
  35.     Dim G_objService                
  36.     Dim G_objSites
  37.  
  38.     '-------------------------------------------------------------------------
  39.     ' Start of localization content
  40.     '-------------------------------------------------------------------------
  41.     Dim L_FTPTASKTITLETEXT
  42.     Dim L_WEBROOTDIR
  43.     Dim L_ENABLEFTP
  44.     Dim L_DIRLISTINGSTYLE 
  45.     Dim L_MAX_CONNECTIONSTEXT
  46.     Dim L_CON_TIMEOUT 
  47.     Dim L_SECONDSTEXT 
  48.     Dim L_NOT_NTFS_DRIVE_ERRORMESSAGE 
  49.     Dim L_FAILED_CREATE_DIR_ERRORMESSAGE
  50.     Dim L_INVALID_DRIVE_ERRORMESSAGE
  51.     Dim    L_UNABLE_TO_SETREGISTRY 
  52.     Dim L_UNABLE_TO_SETMASTERSETTINGS
  53.     Dim L_CONLIMIT_ERRORMESSAGE 
  54.     Dim L_CONTIMEOUT_ERRORMESSAGE 
  55.     Dim L_UNABLETOCREATE_KEY_ERRORMESSAGE
  56.     Dim L_SET_WEBROOT_VAL_FAILED_ERRORMESSAGE 
  57.     Dim L_FAIL_TO_GET_FTPSITEROOT_DIR
  58.     Dim L_INVALID_DIR_FORMAT_ERRORMESSAGE 
  59.     Dim L_INVALID_DIR_ERRORMESSAGE            
  60.     Dim L_DIRPATHEMPTY_ERRORMESSAGE
  61.     Dim L_FTPNOTINSTALLED_ERRORMESSAGE
  62.     Dim L_ENABLE_FTP_SERVICE
  63.     Dim L_ID_NOTEMPTY_ERROR_MESSAGE
  64.     Dim L_SITE_IDENTIFIER_EMPTY_TEXT
  65.     Dim L_CREATEADMINFTPSERVER_ERRORMESSAGE
  66.             
  67.     L_FTPTASKTITLETEXT                        =    GetLocString("GeneralSettings.dll", "4042001A", "")
  68.     L_WEBROOTDIR                            =    GetLocString("GeneralSettings.dll", "4042001B", "")    
  69.     L_ENABLEFTP                                =    GetLocString("GeneralSettings.dll", "4042001D", "")    
  70.     L_DIRLISTINGSTYLE                        =    GetLocString("GeneralSettings.dll", "4042001F", "")
  71.     L_MAX_CONNECTIONSTEXT                    =    GetLocString("GeneralSettings.dll", "40420008", "")
  72.     L_CON_TIMEOUT                            =    GetLocString("GeneralSettings.dll", "40420021", "")
  73.     L_SECONDSTEXT                            =    GetLocString("GeneralSettings.dll", "40420006", "")
  74.     L_NOT_NTFS_DRIVE_ERRORMESSAGE            =    GetLocString("GeneralSettings.dll", "C042000D", "")
  75.     L_FAILED_CREATE_DIR_ERRORMESSAGE        =    GetLocString("GeneralSettings.dll", "C042000E", "")
  76.     L_INVALID_DRIVE_ERRORMESSAGE            =    GetLocString("GeneralSettings.dll", "C0420022", "")
  77.     L_UNABLE_TO_SETREGISTRY                    =    GetLocString("GeneralSettings.dll", "C0420055", "")
  78.     L_UNABLE_TO_SETMASTERSETTINGS            =    GetLocString("GeneralSettings.dll", "C0420054", "")
  79.     L_CONLIMIT_ERRORMESSAGE                    =    GetLocString("GeneralSettings.dll", "C042000B", "")
  80.     L_CONTIMEOUT_ERRORMESSAGE                =    GetLocString("GeneralSettings.dll", "C0420053", "")
  81.     L_UNABLETOCREATE_KEY_ERRORMESSAGE        =    GetLocString("GeneralSettings.dll", "C0420018", "")
  82.     L_SET_WEBROOT_VAL_FAILED_ERRORMESSAGE    =    GetLocString("GeneralSettings.dll", "C0420019", "")
  83.     L_FAIL_TO_GET_FTPSITEROOT_DIR            =    GetLocString("GeneralSettings.dll", "C0420023", "")
  84.     L_INVALID_DIR_FORMAT_ERRORMESSAGE        =    GetLocString("GeneralSettings.dll", "40420004", "")
  85.     L_INVALID_DIR_ERRORMESSAGE                =    GetLocString("GeneralSettings.dll", "C042004B", "")
  86.     L_DIRPATHEMPTY_ERRORMESSAGE                =    GetLocString("GeneralSettings.dll", "C042004C", "")
  87.     L_FTPNOTINSTALLED_ERRORMESSAGE            =    GetLocString("GeneralSettings.dll", "C0420058", "")    
  88.     L_ENABLE_FTP_SERVICE                    =   GetLocString("GeneralSettings.dll", "4042005B", "")    
  89.     L_CREATEADMINFTPSERVER_ERRORMESSAGE        =   GetLocString("GeneralSettings.dll", "4042005D", "")    
  90.     '-------------------------------------------------------------------------
  91.     'END of localization content
  92.     '-------------------------------------------------------------------------
  93.     
  94.     'Create property page
  95.     Dim rc
  96.     Dim page
  97.  
  98.     rc=SA_CreatePage(L_FTPTASKTITLETEXT,"",PT_PROPERTY,page)
  99.    
  100.     'Serve the page
  101.     If(rc=0) then
  102.         SA_ShowPage(page)
  103.     End if
  104.         
  105.     '-------------------------------------------------------------------------
  106.     'Function:                OnInitPage()
  107.     'Description:            Called to signal first time processing for this page.
  108.     '                        Use this method to do first time initialization tasks
  109.     'Input Variables:        PageIn,EventArg
  110.     'Output Variables:        None
  111.     'Returns:                True/False
  112.     'Global Variables:        None
  113.     '-------------------------------------------------------------------------
  114.     Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  115.         
  116.         InitObjects()
  117.         
  118.         if FTPInstalled = false then
  119.             ServeFailurePage L_FTPNOTINSTALLED_ERRORMESSAGE ,sReturnURL
  120.         end if
  121.         
  122.         SetVariablesFromSystem()
  123.         OnInitPage = True
  124.     End Function
  125.     
  126.     '-------------------------------------------------------------------------
  127.     'Function:                OnServePropertyPage()
  128.     'Description:            Called when the page needs to be served.Use this 
  129.     '                        method to serve content
  130.     'Input Variables:        PageIn,EventArg
  131.     'Output Variables:        None
  132.     'Returns:                True/False
  133.     'Global Variables:        None
  134.     '-------------------------------------------------------------------------
  135.     Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  136.         
  137.         Call ServeCommonJavaScript()
  138.         Call ServePage()
  139.         OnServePropertyPage = True
  140.     End Function
  141.     
  142.     '-------------------------------------------------------------------------
  143.     'Function:                OnPostBackPage()
  144.     'Description:            Called to signal that the page has been posted-back.
  145.     'Input Variables:        PageIn,EventArg
  146.     'Output Variables:        None
  147.     'Returns:                True/False
  148.     'Global Variables:        None
  149.     '-------------------------------------------------------------------------
  150.     Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  151.         OnPostBackPage = True
  152.     End Function
  153.         
  154.     '-------------------------------------------------------------------------
  155.     'Function:                OnSubmitPage()
  156.     'Description:            Called when the page has been submitted for processing.
  157.     '                        Use this method to process the submit request.
  158.     'Input Variables:        PageIn,EventArg
  159.     'Output Variables:        None
  160.     'Returns:                True/False
  161.     'Global Variables:        None
  162.     '-------------------------------------------------------------------------
  163.     Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  164.  
  165.         OnSubmitPage = ServeVariablesFromForm()        
  166.     
  167.     End Function
  168.            
  169.     '-------------------------------------------------------------------------
  170.     'Function:                OnClosePage()
  171.     'Description:            Called when the page is about closed.Use this method
  172.     '                        to perform clean-up processing
  173.     'Input Variables:        PageIn,EventArg
  174.     'Output Variables:        None
  175.     'Returns:                True/False
  176.     'Global Variables:        None
  177.     '-------------------------------------------------------------------------
  178.     Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  179.         OnClosePage = TRUE
  180.     End Function     
  181.     
  182.     '-------------------------------------------------------------------------
  183.     'Function:                ServeCommonJavaScript
  184.     'Description:            Serves in initialiging the values,setting the form
  185.     '                        data and validating the form values
  186.     'Input Variables:        None
  187.     'Output Variables:        None
  188.     'Returns:                True/False
  189.     'Global Variables:        None
  190.     '-------------------------------------------------------------------------
  191.     Function ServeCommonJavaScript()
  192. %>        
  193.         <!-- #include virtual="/admin/wsa/inc_wsa.js" -->
  194.         <script language="JavaScript">    
  195.  
  196.             //init function  
  197.             function Init() 
  198.             {   
  199.               var FTPinst = "<%=Server.HTMLEncode(FTPInstalled)%>";
  200.               if (FTPinst == "False")
  201.               {                
  202.                 document.frmTask.selectDirListStyle.disabled = true;
  203.                 document.frmTask.txtMaxCon.disabled = true;
  204.                 document.frmTask.txtConTimeOut.disabled = true;
  205.                                 
  206.                 document.frmTask.selectDirListStyle.disabled = true;
  207.                 document.frmTask.txtMaxCon.value = "";
  208.                 document.frmTask.txtConTimeOut.value = "";
  209.                                 
  210.                 document.frmTask.selectDirListStyle.style.backgroundColor = "c0c0c0";
  211.                 document.frmTask.txtMaxCon.style.backgroundColor = "c0c0c0";
  212.                 document.frmTask.txtConTimeOut.style.backgroundColor = "c0c0c0";            
  213.                 
  214.               }
  215.                         
  216.             }
  217.             
  218.             //Validates user input        
  219.  
  220.             function ValidatePage()
  221.             {
  222.  
  223.                  var FTPinst = "<%=Server.HTMLEncode(FTPInstalled)%>";
  224.                 if (FTPinst == "True")
  225.                 {                    
  226.                      var ConTime = document.frmTask.txtConTimeOut.value;
  227.                      var MaxCon = document.frmTask.txtMaxCon.value;
  228.                      
  229.                      if( MaxCon =="" )
  230.                      {                 
  231.                         SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONLIMIT_ERRORMESSAGE)) %>");
  232.                         return false;
  233.                      }
  234.                 }
  235.                 var ConTime = document.frmTask.txtConTimeOut.value;
  236.                 var MaxCon = document.frmTask.txtMaxCon.value;
  237.                      
  238.                 if(ConTime=="" || ConTime==0)
  239.                 {                 
  240.                    SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONTIMEOUT_ERRORMESSAGE))%>");
  241.                    return false;
  242.                 }
  243.                 
  244.                 if(MaxCon=="" || MaxCon == 0)
  245.                 {                 
  246.                    SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONLIMIT_ERRORMESSAGE)) %>");
  247.                    return false;
  248.                 }
  249.                   
  250.                     UpdateHiddenVariables();
  251.                     return true;
  252.             }                        
  253.             
  254.                         
  255.             function checkKeyforValidCharacters(strID)
  256.             {    
  257.                             
  258.                 var len = strID.length;
  259.                 var charAtPos;
  260.                 if(len > 0)
  261.                 {        
  262.                     for(var i=0; i<len;i++)
  263.                     {
  264.                       charAtPos = strID.charCodeAt(i);                        
  265.                         if(charAtPos ==47 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44)
  266.                         {    
  267.                             SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALID_DIR_ERRORMESSAGE))%>");
  268.                             return false;
  269.                         }
  270.                     }                
  271.                     return true;
  272.                 }
  273.                 else 
  274.                 {    
  275.                     SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_DIRPATHEMPTY_ERRORMESSAGE))%>");
  276.                     return false;
  277.                 }
  278.                 
  279.             }        
  280.             
  281.             
  282.             
  283.             function checkforEmptyMaxCon()
  284.             {
  285.                 var strMaxCon = document.frmTask.txtMaxCon.value; 
  286.                 if (strMaxCon == "" )
  287.                 {                    
  288.                     SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONTIMEOUT_ERRORMESSAGE)) %>");
  289.                     document.frmTask.txtMaxCon.focus();
  290.                     return false;
  291.                 }
  292.                 
  293.                 if (strMaxCon == 0 )
  294.                 {
  295.                     document.frmTask.txtMaxCon.value =1;
  296.                 }        
  297.                 
  298.             }
  299.             
  300.             function checkforEmptyConTimeOut()
  301.             {
  302.                 var strConTimeOut = document.frmTask.txtConTimeOut.value; 
  303.                 if (strConTimeOut == "")
  304.                 {
  305.                     SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONTIMEOUT_ERRORMESSAGE)) %>");
  306.                     document.frmTask.txtConTimeOut.focus();
  307.                     return false;
  308.                 }
  309.                 if (strConTimeOut == 0)
  310.                 {
  311.                     
  312.                     document.frmTask.txtConTimeOut.value = 1;
  313.                 }
  314.             }
  315.         
  316.             function SetData()
  317.             {
  318.                 UpdateHiddenVariables();
  319.             }
  320.                 
  321.             function UpdateHiddenVariables()
  322.             {
  323.                 document.frmTask.hdnFTPEnabled.value = document.frmTask.chkEnableFTP.checked;                
  324.                 document.frmTask.hdnFTPMaxCon.value = document.frmTask.txtMaxCon.value;
  325.                 document.frmTask.hdnFTPConTimeout.value = document.frmTask.txtConTimeOut.value;
  326.                 document.frmTask.hdnFTPListStyle.value = document.frmTask.selectDirListStyle.options[document.frmTask.selectDirListStyle.selectedIndex].value;
  327.             }
  328.             
  329.             // Enable FTP clicked
  330.             function EnableFtp()
  331.             {    
  332.                 EnableOK();                                
  333.                 
  334.                 if ( document.frmTask.chkEnableFTP.checked == false )
  335.                 {                                            
  336.                     document.frmTask.selectDirListStyle.disabled = true;
  337.                     document.frmTask.txtMaxCon.disabled = true;
  338.                     document.frmTask.txtConTimeOut.disabled = true;
  339.                 }
  340.                 else
  341.                 {                            
  342.                     document.frmTask.selectDirListStyle.disabled = false;
  343.                     document.frmTask.txtMaxCon.disabled = false;
  344.                     document.frmTask.txtConTimeOut.disabled = false;
  345.                 }                
  346.              }
  347.         </script>
  348.         
  349. <%    End Function
  350.    
  351.     '-------------------------------------------------------------------------
  352.     'Function:                ServePage()
  353.     'Description:            For displaying outputs HTML to the user
  354.     'Input Variables:        None    
  355.     'Output Variables:        None
  356.     'Returns:                None
  357.     'Global Variables:        L_DELETE_CONFIRM_TEXT
  358.     '-------------------------------------------------------------------------
  359.     Function ServePage
  360. %>
  361.         </h5><br><BR>
  362.         <TABLE border=0 cellPadding=1 cellSpacing=1 style="LEFT: 12px; TOP: 15px" class="TasksBody">
  363.             
  364.             
  365.             <%
  366.             
  367.               Dim bIsFTPEnabled
  368.               
  369.               bIsFTPEnabled = false
  370.             
  371.               if IsFTPEnabled() Then ' Check if FTP service is running
  372.                 if IsAdminFTPServerExistAndRunning() Then     ' Check if admin FTP server        
  373.                     bIsFTPEnabled = true                    ' exists and is running
  374.                 End If
  375.               End If
  376.             
  377.             %>
  378.             
  379.             <TR>
  380.                 <TD width="50%">
  381.                    
  382.                     <% if bIsFTPEnabled then%>                                     
  383.                         <INPUT TYPE=checkbox NAME=chkEnableFTP class="formField" value="true" checked tabIndex=1">
  384.                     <% else %>
  385.                         <INPUT TYPE=checkbox NAME=chkEnableFTP class="formField" value="false" tabIndex=1">
  386.                     <% end if %>
  387.                        <%=L_ENABLE_FTP_SERVICE%>                    
  388.                 </TD>                
  389.             </TR>
  390.  
  391.             <TR>
  392.                 <TD>
  393.                      
  394.                 </TD>
  395.             </TR>
  396.             <TR>
  397.                 <TD>
  398.                    
  399.                     <%=L_DIRLISTINGSTYLE%>
  400.                 </TD>
  401.                 <TD>
  402.                 
  403.                     <SELECT  name=selectDirListStyle style="HEIGHT: 22px; WIDTH: 85px" tabIndex=3 class="formField" value="<%=F_selectDirListStyle%>">
  404.                     
  405.                     <% if F_selectDirListStyle = "UNIX" then %>
  406.                         <OPTION selected value="UNIX">UNIX</OPTION>
  407.                         <OPTION value="MS-DOS">MS-DOS</OPTION>
  408.                     <%else%>
  409.                         <OPTION  value="UNIX">UNIX</OPTION>
  410.                         <OPTION selected value="MS-DOS">MS-DOS</OPTION>
  411.                     <%end if%>
  412.                     </SELECT>
  413.                 </TD>
  414.             </TR>
  415.             <TR>
  416.                 <TD>
  417.                      
  418.                 </TD>
  419.             </TR>
  420.             <TR>
  421.                 <TD>        
  422.                            
  423.                     <%=L_MAX_CONNECTIONSTEXT%>
  424.                 </TD>
  425.                 
  426.                 <TD>                                
  427.                     <INPUT name=txtMaxCon  size=10  class="formField" tabIndex=4 value="<%=F_FTPMaxCon%>" OnKeyUP="javaScript:checkUserLimit(this,'conftp');" OnKeypress="javaScript:checkKeyforNumbers(this);" onblur = "checkforEmptyMaxCon();">                                    
  428.                 </TD>
  429.             </TR>
  430.     
  431.             <TR>
  432.                 <TD>
  433.                      
  434.                 </TD>
  435.             </TR>
  436.             <TR>
  437.                 <TD>
  438.                 
  439.                    
  440.                 
  441.                     <%=L_CON_TIMEOUT%>
  442.                 </TD>
  443.                 <TD>
  444.                     <INPUT name=txtConTimeOut size=10  class="formField" tabIndex=5 value="<%=F_FTPCon_Timeout%>" OnKeyUP="javaScript:checkUserLimit(this,'contimeout');" OnKeypress="javaScript:checkKeyforNumbers(this);" onblur = "checkforEmptyConTimeOut()">                    
  445.                 </TD>
  446.             </TR>
  447.     
  448.         </TABLE>
  449.  
  450.         
  451.         <input type=hidden name=hdnFTPMaxCon value = "<%=F_FTPMaxCon%>" >
  452.         <input type=hidden name=hdnFTPConTimeout value = "<%=F_FTPCon_Timeout%>" >
  453.         <input type=hidden name=hdnFTPListStyle value = "<%=F_selectDirListStyle%>" >
  454.         <input type=hidden name=hdnFTPEnabled>
  455.         
  456.         
  457. <%                
  458.     End Function
  459.     
  460.     '-------------------------------------------------------------------------
  461.     'Function name:            ServeVariablesFromForm()
  462.     'Description:            Serves in getting the data from Client 
  463.     'Input Variables:        None    
  464.     'Output Variables:        None
  465.     'Returns:                True/False
  466.     'Global Variables:        None
  467.     '-------------------------------------------------------------------------
  468.     Function ServeVariablesFromForm
  469.     
  470.         'setting the form variables        
  471.         F_selectDirListStyle = Request.Form("hdnFTPListStyle")
  472.         F_FTPMaxCon = Request.Form("hdnFTPMaxCon")
  473.         F_FTPCon_Timeout = Request.Form("hdnFTPConTimeout")        
  474.         F_FTPEnabled = Request.Form("hdnFTPEnabled")
  475.         
  476.         'set the FTP master settings
  477.         If ConfigWebServer()then
  478.            ServeVariablesFromForm = true
  479.         else
  480.             ServeVariablesFromForm = false
  481.         end if    
  482.  
  483.     End Function    
  484.  
  485.     '-------------------------------------------------------------------------
  486.     'Function name:            InitObjects
  487.     'Description:            Initialization of global variables is done
  488.     'Input Variables:        None
  489.     'Returns:                true/false
  490.     'Global Variables:        G_objService
  491.     '                        G_objSites
  492.     '--------------------------------------------------------------------------
  493.     
  494.     Function InitObjects()
  495.         Err.Clear
  496.         on error resume next
  497.         
  498.         ' Get instances of IIS_FTPServiceSetting that are visible throughout
  499.         Set G_objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  500.         set G_objSites = G_objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPServiceSetting"))
  501.  
  502.         if Err.number <> 0 or G_objSites.count = 0 then    
  503.             FTPInstalled = false
  504.             Err.Clear
  505.         else
  506.             FTPInstalled = true
  507.         end if
  508.         
  509.     end function
  510.     
  511.     '-------------------------------------------------------------------------
  512.     'Function name:            ConfigWebServer
  513.     'Description:            Sets Master Settings
  514.     'Input Variables:        None
  515.     'Returns:                true/false
  516.     'Global Variables:        G_objService
  517.     '                        G_objSites
  518.     '--------------------------------------------------------------------------
  519.     
  520.     Function ConfigWebServer()    
  521.         
  522.         Err.Clear
  523.         on error resume next
  524.         
  525.         ConfigWebServer = false
  526.         
  527.         'init global var FTPInstalled
  528.         InitObjects()
  529.             
  530.         '
  531.         ' First, set the proper state for FTP service
  532.         '        
  533.         ' If user select to enable FTP service
  534.         if F_FTPEnabled = "true" Then
  535.             'If FTP Service is not started, we need to start it
  536.             'and set it state to automatic
  537.             If Not IsFTPEnabled Then      
  538.                 Call EnableFTP()            
  539.             End If
  540.             
  541.             if Not IsAdminFTPServerExistAndRunning() Then
  542.  
  543.                 If IsAdminFTPServerExist() Then                                        
  544.             
  545.                     'Stop the running FTP server
  546.                     If Not StopDefaultFTPServer() Then                                
  547.                         SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  548.                         Exit Function
  549.                     End If
  550.                     
  551.                     If Not StartAdminFTPServer() Then
  552.                         SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  553.                         Exit Function
  554.                     End If
  555.  
  556.                 Else 
  557.  
  558.                     'If admin FTP server does not exist, create and start it
  559.                     'when create it, it will start be default.
  560.                     If Not CreateAdminFTPServer() Then
  561.                         SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  562.                         Exit Function
  563.                     End If
  564.                     
  565.                     'Stop the running FTP server
  566.                     If Not StopDefaultFTPServer() Then                                
  567.                         SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  568.                         Exit Function
  569.                     End If
  570.                     
  571.                     If Not StartAdminFTPServer() Then
  572.                         SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  573.                         Exit Function
  574.                     End If
  575.                     
  576.                 End If
  577.                 
  578.             End If                
  579.                                                     
  580.         elseif F_FTPEnabled = "false" Then
  581.         
  582.             'If admin FTP server is running, stop it. Otherwise, do nothing.
  583.             if IsAdminFTPServerExistAndRunning() Then                            
  584.                 if StopAdminFTPServer() Then
  585.                     ConfigWebServer = true  
  586.                 Else
  587.                     SA_TraceOut "Ftp_MasterSettings", "Failed to stop admin FTP Server"
  588.                 End If                    
  589.             End If
  590.                     
  591.         else
  592.         
  593.             Call SA_TraceOut("Ftp_MasterSettings.asp", "ConfigWebServer(): Unexpected Error")
  594.         
  595.         End If
  596.         
  597.         'Set the FTP mastersettings
  598.           if FTPInstalled = true then
  599.             if NOT SetMasterSiteSettings() then                
  600.                 ServeFailurePage L_UNABLE_TO_SETMASTERSETTINGS ,sReturnURL
  601.                 exit function
  602.             end if
  603.         end if                    
  604.         
  605.         'Release the objects
  606.         set G_objSites = nothing
  607.         set G_objService = nothing
  608.         
  609.         ConfigWebServer = true
  610.         
  611.     end function
  612.     
  613.     '-------------------------------------------------------------------------
  614.     'Function name:            ValidateInputs
  615.     'Description:            Validates the inputs
  616.     'Input Variables:        None
  617.     'Returns:                true/false
  618.     'Global Variables:        None
  619.     '--------------------------------------------------------------------------
  620.     
  621.     Function ValidateInputs()
  622.         Err.Clear
  623.         on error resume next
  624.         Dim objFso,nRetVal
  625.  
  626.         ValidateInputs = false
  627.         
  628.         ' Check whether directory exists
  629.         ' If directory does not exist, create the web site if the drive letter is valid
  630.         ' else give error message
  631.         
  632.         Set objFso = server.CreateObject("Scripting.FileSystemObject")
  633.         if Err.number <> 0 then
  634.             SetErrMsg L_FILEINFORMATION_ERRORMESSAGE
  635.             exit function
  636.         end if            
  637.         
  638.         'nRetVal = CreateSitePath( objFso, F_FTPRootDir )    
  639.                 
  640.         if nRetVal <> CONST_SUCCESS then
  641.  
  642.             if nRetVal = CONST_INVALID_DRIVE then
  643.  
  644.                 SetErrMsg L_INVALID_DRIVE_ERRORMESSAGE
  645.  
  646.             elseif nRetVal = CONST_NOTNTFS_DRIVE then
  647.     
  648.                 SetErrMsg L_NOT_NTFS_DRIVE_ERRORMESSAGE
  649.             
  650.             else
  651.             
  652.                 SetErrMsg L_FAILED_CREATE_DIR_ERRORMESSAGE
  653.             
  654.             end if
  655.  
  656.  
  657.             exit Function
  658.  
  659.         end if
  660.  
  661.         'release the object
  662.         set objFso = nothing
  663.         
  664.         ValidateInputs = true 
  665.     
  666.     End Function
  667.     
  668.     
  669.     '-------------------------------------------------------------------------
  670.     'Function name:            SetMasterSiteSettings
  671.     'Description:            sets the FTP master settings
  672.     'Input Variables:        None
  673.     'Returns:                true/false
  674.     'Global Variables:        None
  675.     '--------------------------------------------------------------------------
  676.  
  677.     Function SetMasterSiteSettings()
  678.         Err.Clear
  679.         on error resume next
  680.         
  681.         Dim instSite        
  682.         Dim objService
  683.         Dim objSites
  684.         
  685.         SetMasterSiteSettings = false        
  686.         
  687.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  688.         
  689.         set objSites = objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPServiceSetting"))
  690.  
  691.         if Err.number <> 0 or objSites.count = 0 then
  692.             
  693.             exit function
  694.         end if
  695.                 
  696.         for each instSite in objSites            
  697.             
  698.             if instSite.Name = "MSFTPSVC" then
  699.             
  700.                 'instSite.AllowAnonymous    = F_FTPAllowAnonymous
  701.                 
  702.                 if     F_selectDirListStyle = "UNIX" then
  703.                     instSite.MSDosDirOutput = false
  704.                 else
  705.                     instSite.MSDosDirOutput = true
  706.                 end if
  707.                     
  708.                 'set max connections
  709.                 if trim(F_FTPMaxCon) = "" then
  710.                     instSite.MaxConnections = 100000
  711.                 else
  712.                     instSite.MaxConnections = clng(F_FTPMaxCon)
  713.                 end if
  714.             
  715.                 'set connection timeout
  716.                 if trim(F_FTPCon_Timeout) = "" then
  717.                     instSite.ConnectionTimeout = 900
  718.                 else
  719.                     instSite.ConnectionTimeout = clng(F_FTPCon_Timeout)
  720.                 end if    
  721.                 instSite.Put_(WBEMFLAG)                
  722.                 
  723.                 if err.number <> 0 then
  724.                     SA_TraceOut "FTP_Master Settings", "Unable to set the FTP Master Settings"
  725.                     exit function
  726.                 end if
  727.                 
  728.                 SetMasterSiteSettings = true
  729.             
  730.                 exit for
  731.             
  732.             end if
  733.         next
  734.         
  735.         'Release the objects
  736.         set objSites = nothing
  737.         set objService = nothing    
  738.         
  739.         SetMasterSiteSettings = true
  740.  
  741.     End Function
  742.     
  743.     '-------------------------------------------------------------------------
  744.     'Function name:            SetWebSiteRootVal
  745.     'Description:            sets the FTP site root dir to the registry key
  746.     'Input Variables:        strWebRootDir
  747.     'Returns:                true/false
  748.     'Global Variables:        None
  749.     '--------------------------------------------------------------------------
  750.  
  751.     Function SetWebSiteRootVal(strWebRootDir)
  752.         Err.Clear
  753.         on error resume next
  754.         
  755.         Dim IRC, objGetHandle, rtnCreateKey
  756.     
  757.         SetWebSiteRootVal = FALSE
  758.     
  759.         set objGetHandle = RegConnection()
  760.         
  761.         rtnCreateKey = RegCreateKey(objGetHandle,CONST_WEBBLADES_REGKEY)
  762.         If Err.number <> 0 then
  763.             SetErrMsg L_UNABLETOCREATE_KEY_ERRORMESSAGE
  764.             exit function
  765.         end if
  766.                 
  767.         IRC = objGetHandle.SetStringValue(G_HKEY_LOCAL_MACHINE,CONST_WEBBLADES_REGKEY,CONST_FTPSITEROOT_REGVAL,strWebRootDir)
  768.  
  769.         If Err.number <> 0 then
  770.             SetErrMsg L_SET_WEBROOT_VAL_FAILED_ERRORMESSAGE
  771.             exit function
  772.         end if
  773.     
  774.         'release the object
  775.         set objGetHandle = nothing
  776.         
  777.         SetWebSiteRootVal = TRUE
  778.     
  779.     End Function
  780.     
  781.     '-------------------------------------------------------------------------
  782.     'Function name:            SetVariablesFromSystem
  783.     'Description:            Serves in Getting the data from Client 
  784.     'Input Variables:        None    
  785.     'Output Variables:        None
  786.     'Returns:                None
  787.     'Global Variables:        G_objSites
  788.     '-------------------------------------------------------------------------
  789.  
  790.     Function SetVariablesFromSystem
  791.         Err.Clear
  792.         on Error resume next
  793.  
  794.         Dim nRetval
  795.         Dim instSite
  796.                 
  797.         for each instSite in G_objSites
  798.             
  799.             if instSite.Name = "MSFTPSVC" then
  800.                     
  801.                 if instSite.MSDosDirOutput = false then    'get Directory listing style
  802.                      F_selectDirListStyle = "UNIX"
  803.                 else
  804.                     F_selectDirListStyle = "MS-DOS"
  805.                 end if
  806.                     
  807.                 F_FTPMaxCon = instSite.MaxConnections 'get max connection value
  808.                     
  809.                 F_FTPCon_Timeout = instSite.ConnectionTimeout 'get connection timeout value
  810.                     
  811.                 exit for
  812.                     
  813.             end if
  814.         next
  815.         
  816.     End Function
  817. %>
  818.